package com.sk.dao;

import org.hibernate.Session;

import com.sk.pojo.Detail;



public class DetailDao implements BaseDao1 {
	@Override
	public boolean save(Object object) {
		Session session = getSession();
		if(object instanceof Detail){
			try {
				session.beginTransaction();
				session.save(object);
				session.getTransaction().commit();
				
				return true;
			} catch (Exception e) {
				e.printStackTrace();
				session.getTransaction().rollback();
				
			}
		}
		return false;
	}

	private Session getSession() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object get(Object object) {
		Session session = getSession();
		if(object instanceof Integer){
			session.beginTransaction();
			int id = (int) object;
			Detail detail  = (Detail) session.get(Detail.class,id);
			
			return detail;
		}
		return null;
	}

	@Override
	public boolean delete(Object object) {
		Session session = getSession();
		if(object instanceof Detail){
			try {
				session.beginTransaction();
				session.delete(object);
				session.getTransaction().commit();			
				
				return true;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				session.getTransaction().rollback();
				
			}
		}
		return false;
	}

	@Override
	public boolean update(Object object) {
		Session session = getSession();
		if(object instanceof Detail){
			try {
				session.beginTransaction();
				session.update(object);
				session.getTransaction().commit();			
				
				return true;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				session.getTransaction().rollback();
				
			}
		}
		return false;
	}
}
